package collection;

import java.util.*;

public class SortListDemo2 {
    public static void main(String[] args) {
        List<Point> list = new ArrayList<>();
        list.add(new Point(41,62));
        list.add(new Point(5,7));
        list.add(new Point(16,38));
        list.add(new Point(7,9));
        list.add(new Point(8,10));
        list.add(new Point(9,11));

        System.out.println(list);

        Collections.sort(list,(o1, o2) -> {
            return o1.getX()*o1.getX()+o1.getY()*o1.getY()-o2.getX()*o2.getX()-o2.getY()*o2.getY();//升序
           // return o2.getX()*o2.getX()+o2.getY()*o2.getY()-o1.getX()*o1.getX()-o1.getY()*o1.getY();//降序
        });
        System.out.println(list);
    }
}
